/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PatientPrimaryDoctorPanel.java
 *
 * Created on Aug 14, 2011, 9:41:30 PM
 */
package panels;

import conn.EMIS4Connection;
import constants.Constants;
import dao.PersonDao;
import dao.UpdateHistoryDao;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import obj.Person;
import obj.UpdateHistory;

/**
 *
 * @author NATHAN
 */
public class PatientPrimaryDoctorPanel extends javax.swing.JPanel {
  
  private EMIS4Connection conn = EMIS4Connection.getInstance();
  private UpdateHistory history;
  private UpdateHistoryDao historyDAO;
  private Person patient, doctor;
  private PersonDao personDAO;
  private List<Person> doctorList;

  /** Creates new form PatientPrimaryDoctorPanel */
  public PatientPrimaryDoctorPanel() {
    
    history = new UpdateHistory();
    historyDAO = new UpdateHistoryDao();
    patient = new Person();
    doctor = new Person();
    personDAO = new PersonDao();
    
    initComponents();
    
    fillInformation();
  }
  
  private void fillInformation() {
    try {
      doctor.setRoleID(Constants.DOCTOR);
      
      conn.connect();
      doctorList = personDAO.searchMatching(conn.getConnection(), doctor);
      
      for (Person item : doctorList) {
        doctorComboBox.addItem(item.getLastName() + ", " + item.getFirstName());
      }
      
      
      
      
      
    } catch (SQLException ex) {
      Logger.getLogger(PatientPrimaryDoctorPanel.class.getName()).log(Level.SEVERE, null, ex);
    }
    
  }

  /** This method is called from within the constructor to
   * initialize the form.
   * WARNING: Do NOT modify this code. The content of this method is
   * always regenerated by the Form Editor.
   */
  @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();
    doctorComboBox = new javax.swing.JComboBox();

    setBackground(new java.awt.Color(220, 220, 210));
    setLayout(new java.awt.GridBagLayout());

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
    jLabel1.setText("Primary Doctor");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.insets = new java.awt.Insets(20, 15, 10, 15);
    add(jLabel1, gridBagConstraints);

    jLabel2.setText("Doctor:");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.insets = new java.awt.Insets(10, 25, 0, 0);
    add(jLabel2, gridBagConstraints);

    jButton1.setText("Submit");
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(15, 70, 20, 15);
    add(jButton1, gridBagConstraints);

    doctorComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "None" }));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
    gridBagConstraints.insets = new java.awt.Insets(6, 6, 0, 0);
    add(doctorComboBox, gridBagConstraints);
  }// </editor-fold>//GEN-END:initComponents
  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JComboBox doctorComboBox;
  private javax.swing.JButton jButton1;
  private javax.swing.JLabel jLabel1;
  private javax.swing.JLabel jLabel2;
  // End of variables declaration//GEN-END:variables
}
